package com.liesheng.haylou.db;

import android.content.Context;

import com.liesheng.haylou.app.HyApplication;
import com.liesheng.haylou.bean.UserAccount;

import java.util.List;

/**
 * Date:2019/11/7
 * <p>
 * Author:wuzhiguang
 * <p>
 * Description:
 */
public class DBManager {

    private final String DB_NAME = "haylou_db.db";
    private Context mContext;
    private static DBManager instance;
    private DaoSession daoSession;


    private DBManager(Context mContext) {
        this.mContext = mContext;
    }

    public static DBManager getInstance(){
        if (instance==null){
            synchronized (DBManager.class){
                if (instance==null){
                    instance = new DBManager(HyApplication.mApp);
                }
            }
        }
        return instance;
    }

    public void init(){
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(mContext,DB_NAME);
        DaoMaster master = new DaoMaster(helper.getWritableDb());
        daoSession = master.newSession();
        daoSession.clear();
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}
